<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
   <form>
       姓名:<input type="text" name="name" placeholder="名字"><br>
       工作:<input type="text" name="job" placeholder="工作"><br>
       薪资:<input type="text" name="sal" placeholder="薪资"><br>
       <input type="button" value="新增" @click="add()">
   </form>
    <!--引入axios和vue-->
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.14/vue.js"></script>
    <script>
        let v = new Vue({
            el:"form",
            data:{},
            methods:{
                add:function () {
                    let data = new FormData(document.querySelector("form"));
                    axios.post("/insert",data).then(function (res) {
                        alert("/添加完成!");
                        location.href="/";//回到首页
                    })
                }
            }
        })

    </script>

</body>
</html>